package com.deep.spring.stream.io2;

import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import java.util.Optional;

public class TestMethod {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        User user1 = (User) context.getBean("user1");
        user1.printUser();
        User user2 = (User) context.getBean("user2");
        user2.printUser();
    }

    @Test
    public void test() {
        ExpressionParser parser = new SpelExpressionParser();
        Expression exp = parser.parseExpression("new Double(3.1415926)");
        Double value = exp.getValue(Double.class);
        Optional<Double> optionalDouble = Optional.of(value);

        Assert.assertEquals(Optional.ofNullable(value), 3.1415926);
    }
}